<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Addusr extends CI_Controller {
	
    function __construct() {
        parent::__construct();
    }
    
    function index(){
        $data = array(
            "title" => "Login",
            "jsarray" => array("./resources/js/addusr.js"),
            "extra" => ""
        );
        
        $this->load->view("header", $data);
        $this->load->view("addusr");
        $this->load->view("footer");
    }
    
    function add(){
        $this->load->database();
        $this->load->model("Sys_usr_info");
        
        $email = htmlentities($this->input->post("email",""),ENT_QUOTES);
        $password = htmlentities($this->input->post("password",""),ENT_QUOTES);
        $nickname = htmlentities($this->input->post("nickname",""),ENT_QUOTES);
        
        $u = $this->Sys_usr_info->create_user($email,$password,$nickname);
        if ($u){			
            echo '<div class="info">成功新增用户'.$email.'！</div><script language="javascript">window.location = "'.site_url().'";</script>';
        } else {
            echo '<div class="error">新增用户失败，可能有重名用户，请重新输入！</div>';
        }
            
    }
}

?>